<?php
include_once 'class/db/Database.php';


/**
 * Description of DbProject
 *
 * @author GHoogendoorn
 * @version 0.1
 * 
 * Version history
 * 0.1  GHoogendoorn    Initial version
 */
class DbProject extends Database {

    public function __construct($id='') {
        parent::__construct();
        //Initialisatie
    }

    public function DbProject() {
        
    }
    
    public function getProjectListIds(){
        //Check Id
        
        try {
            $query = "SELECT project_id FROM `project`";

            echo __FILE__ . __LINE__ .": $query<br/>";
            $this->query($query);

            return $this->fetchAll();
        
        } catch (Exception $e){
            trigger_error($e->getMessage());
        }
    }
    
    public function getProjectPersonList($project_id){
        
        try {
            $query = "SELECT `person`.`person_id`,`person_name`,`person_fam_name`, `project_persoon`.`project_person_type_id` FROM".
                    " `project_persoon` LEFT JOIN `person` ON `project_persoon`.`person_id` = `person`.`person_id`".
                    " WHERE `project_persoon`.`project_id` = $project_id" ;
            echo __FILE__ . __LINE__ .": $query<br/>";
            $this->query($query);
            
            return $this->fetchAll();
            
        } catch (Exception $e){
            trigger_error($e->getMessage());
        }

        
    }
    
    public function getProjectList(){
        try {
            $query = "SELECT project_id, projectnaam FROM `project` order by `project_date`";

            // echo __FILE__ . __LINE__ .": $query<br/>";
            $this->query($query);

            return $this->fetchAll();
        
        } catch (Exception $e){
            trigger_error($e->getMessage());
        }
    }

}

class TestDbProject {

    public function TestDbProject() {
        try {
            $test = new DbProject();
        } catch (Exception $e) {
            echo '<pre>';
            echo $e->getTraceAsString();
            echo '</pre>';
            trigger_error($e->getMessage());
        }
    }

}

?>
